package com.edu.exam.enums.grading.correction;

/**
 * 操作结果枚举
 *
 * @author System
 * @version 1.0
 * @since 2025-11-15
 */
public enum CorrectionOperationResult {
    /**
     * 成功
     */
    SUCCESS("Success", "成功"),

    /**
     * 失败
     */
    FAILED("Failed", "失败"),

    /**
     * 部分成功
     */
    PARTIAL_SUCCESS("PartialSuccess", "部分成功"),

    /**
     * 已跳过
     */
    SKIPPED("Skipped", "已跳过");

    private final String code;
    private final String description;

    CorrectionOperationResult(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    /**
     * 根据代码获取操作结果
     *
     * @param code 代码
     * @return 操作结果，找不到时返回默认值SUCCESS
     */
    public static CorrectionOperationResult fromCode(String code) {
        for (CorrectionOperationResult result : values()) {
            if (result.getCode().equals(code)) {
                return result;
            }
        }
        return SUCCESS;
    }
}